package com.bank.daoimpl;

import com.bank.dao.DetailDao;
import com.bank.javabean.Detail;
import com.bank.util.MyJDBCUtil;

import java.util.ArrayList;

/**
 * @Auther: Liu
 */
public class DetailDaoImpl implements DetailDao {
    /**
     * 查询所有数据
     *
     * @param username
     */
    @Override
    public ArrayList<Detail> selectByUnameAndTname(String username) {
        String sql="select * from detail where uname=? or tname=?";
        return MyJDBCUtil.dql(Detail.class,sql,username,username);
    }

    /**
     * 插入数据方法
     *
     * @param detail
     */
    @Override
    public int insertDetail(Detail detail) {
        String sql = "insert into detail (uname,tname,money,time,type)values(?,?,?,now(),?)";
        return MyJDBCUtil.dml(sql, detail.getUname(), detail.getTname(), detail.getMoney(), detail.getType());
    }
}